from app.extensions import db
from app.modules.common.utils import JsonEncoder


class Machine(db.Model, JsonEncoder):
    __tablename__ = "machine"
    id = db.Column(db.Integer, primary_key = True)
    ip = db.Column(db.String)
    cpus = db.Column(db.Integer)
    ram = db.Column(db.Integer)
    disks = db.Column(db.Integer)
    agent_list = None

    def __init__(self, ip, cpus, ram, disks):
        self.ip = ip
        self.cpus = cpus
        self.ram = ram
        self.disks = disks

    def to_dict(self):
        return {
            'id': self.id,
            'ip': self.ip,
            'cpus': self.cpus,
            'ram': self.ram,
            'disks': self.disks,
        }
